package com.fbinggun.fbinggunutil.API;

import com.fbinggun.fbinggunutil.plugin.ItemsAdderUtil;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;

/**
 * 方块处理
 */
public class BlockUtil {

    public static String getType(Block block){
        String str =null;
        if(PluginUtil.isItemsAdder()){
            str= ItemsAdderUtil.getBlockType(block);
        }
        if(str==null){
            return block.getType().toString();
        }
        return str;
    }
    public static  Block getBlock(String id, Location location){
        Block block=null;
        if(PluginUtil.isItemsAdder()){
            block= ItemsAdderUtil.getBlock(id);
        }
        if(block==null){
            block= location.getBlock();
            block.setType(Material.valueOf(id));
        }
        return block;
    }


    public static  Block placeBlock(String id, Location location){
        Block block=null;
        if(PluginUtil.isItemsAdder()){
            block= ItemsAdderUtil.getBlock(id);
        }
        if(block==null){
            block= location.getBlock();
            block.setType(Material.valueOf(id));
        }
        return block;
    }

}
